package com.hzsd.zengbanyi.biaodan_text.MyAdapter;


import java.util.List;




import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hzsd.zengbanyi.biaodan_text.R;
import com.hzsd.zengbanyi.biaodan_text.bean.LabSampleBodyBean;

public class LabSampleAdapter extends BaseAdapter{
	private List<LabSampleBodyBean> bodyBeans;
	private LayoutInflater inflater;
	private Context context;
	
	public LabSampleAdapter(Context context,List<LabSampleBodyBean> bodyBeans) {
		this.context = context;
		this.bodyBeans = bodyBeans;
		this.inflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return bodyBeans.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return bodyBeans.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = inflater.inflate(R.layout.item_lab_sample, parent, false);
			viewHolder.tv_Code = (TextView) convertView.findViewById(R.id.tv_Code);
			viewHolder.tv_Volume = (TextView) convertView.findViewById(R.id.tv_Volume);
			viewHolder.tv_Dilution = (TextView) convertView.findViewById(R.id.tv_Dilution);
			viewHolder.tv_A0 = (TextView) convertView.findViewById(R.id.tv_A0);
			viewHolder.tv_A = (TextView) convertView.findViewById(R.id.tv_A);
			viewHolder.tv_A_Ao = (TextView) convertView.findViewById(R.id.tv_A_Ao);
			viewHolder.tv_Curve = (TextView) convertView.findViewById(R.id.tv_Curve);
			viewHolder.tv_concentration = (TextView) convertView.findViewById(R.id.tv_concentration);
			viewHolder.tv_AverageConcentration = (TextView) convertView.findViewById(R.id.tv_AverageConcentration);
			convertView.setTag(viewHolder);
		}else{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.tv_Code.setText(bodyBeans.get(position).getCode());
		viewHolder.tv_Volume.setText(bodyBeans.get(position).getVolume());
		viewHolder.tv_Dilution.setText(bodyBeans.get(position).getDilution());
		viewHolder.tv_A0.setText(bodyBeans.get(position).getA0());
		viewHolder.tv_A.setText(bodyBeans.get(position).getA());
		viewHolder.tv_A_Ao.setText(bodyBeans.get(position).getA_Ao());
		viewHolder.tv_Curve.setText(bodyBeans.get(position).getCurve());
		viewHolder.tv_concentration.setText(bodyBeans.get(position).getConcentration());
		viewHolder.tv_AverageConcentration.setText(bodyBeans.get(position).getAverageConcentration());
		if (position%2!=0) {
			convertView.setBackgroundColor(context.getResources().getColor(R.color.blue_shallow_1));
		}else{
			convertView.setBackgroundColor(context.getResources().getColor(R.color.blue_shallow_2));
		}
		return convertView;
	}
	class ViewHolder{
		TextView tv_Code;
		TextView tv_Volume;
		TextView tv_Dilution;
		TextView tv_A0;
		TextView tv_A;
		TextView tv_A_Ao;
		TextView tv_Curve;
		TextView tv_concentration;
		TextView tv_AverageConcentration;
	}

}
